package cn.kgc.tafang.service;


import cn.kgc.tafang.entity.User;

import java.io.*;
import java.util.List;
import java.util.Map;

public class UserOpera {
    public static void Seria(Object object, File file){
        ObjectOutputStream ost=null;
        if (file.exists()){
            try {
                ost=new ObjectOutputStream(new FileOutputStream(file));
                ost.writeObject(object);
                ost.flush();
            } catch (IOException e) {
                e.printStackTrace();
            }finally {
                if (ost!=null){
                    try {
                        ost.close();
                    } catch (IOException e) {
                        e.printStackTrace();
                    }
                }
            }
        }
    }
    public static Object unSeria(File file){
        ObjectInputStream ois = null;
        Object object =null;
        try {
            ois=new ObjectInputStream(new FileInputStream(file));
            object= ois.readObject();
        } catch (IOException e) {
            //e.printStackTrace();
            return null;
        } catch (ClassNotFoundException e) {
           // e.printStackTrace();
            return null;
        }finally {
            if (ois!=null){
                try {
                    ois.close();
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
        }
        return object;
    }
}
